/*
 * StepItem
 * 
 * versvion 1.0
 * 
 * 14.05.2009
 * 
 * Copyright (c) StrongQA, Inc.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of StrongQA, Inc.
 * You shall not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with StronQA.Inc.
 *
 */

package reporting;

import static util.ConstantCollection.*;

/**
 * @author Roman I.
 * 
 */
class StepItem {
	
	/**
	 * type can be checkpoint, action or null 
	 */
	private String type;
	
	/**
	 * description of action sub-step
	 */
	private String description;
	
	/**
	 * status of action step, failed or passed 
	 */
	private int status;
	
	/**
	 * text description of error
	 */
	private String errorDescription;
	
	/**
	 * Collection  StackTraceElement for Exception
	 */
	private StackTraceElement[] errorStack = null;	
	
	private String pathToCommonTrace;
	
	/**
	 * the path to the screenshot of error
	 */
	private String screenshot;
	
	/**
	 * number of action step 
	 */
	private String stepNum;
	
	
	/**
	 * Keeps essence from Input/Action and verifications
	 * @param type  can be checkpoint, action or null
	 * @param description description of action sub-step
	 * @param stepnum number of action step
	 * @param status of action step, failed or passed
	 */
	public StepItem(String type, String description, String stepNum) {
		this.type = type;
		this.description = description;		
		this.stepNum = stepNum;
		status = STATUS_UNCHECKED;
	}
 
	/**
	 * @param type, can be checkpoint, action or null
	 */
	public void setType(String type) {
		if ((type == "cp")||(type == "action")) {		
			this.type = type;
		} else {
			System.out.println("Impossible set type for StepItem");
		}
	}
	
	/**
	 * @return type, can be checkpoint, action or null
	 */
	public String getType() {
		return type;
	}
	
	/**
	 * @return description of action step
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * @param status of action step, failed or passed
	 */
	public void setStatus(int status) {
		if (this.status == STATUS_UNCHECKED) {
			this.status = status; 
		} else {
			this.status = STATUS_WARNING;
			System.out.println("Status '" + status + "' of StepItem is incorrect");
		}						
	}
	
	/**
	 * @return status of action step, failed or passed
	 */
	public int getStatus() {
		return status;
	}
	
	/**
	 * @param errorDescription text description of error
	 */
	public void setErrorDescription(String errorDescription) {
		this.errorDescription = errorDescription;
	}
	
	/**
	 * @return text description of error
	 */
	public String getErrorDescription() {
		return errorDescription;
	}
	
	public StackTraceElement[] getErrorStack () {
		return errorStack;
	}
	
	public void setErrorStack(StackTraceElement[] errorStack) {
		this.errorStack = errorStack; 
	}
	
	/**
	 * @param the path to the screenshot of error
	 */
	public void setScreenshot(String screenshot) {
		if (this.screenshot == null) {
			this.screenshot = screenshot;			
		} else {
			System.out.println("Impossible set 'Screenshot' one more time");
		}
	}
	
	/**
	 * @return the path to the screenshot of error
	 */
	public String getScreenshot() {
		return screenshot;
	}
	
	/**
	 * @return stepNum number of action step
	 */
	public String getStepNum() {
		return stepNum;
	}
	
	/**
	 * @return
	 */
	public String getPathToCommonTrace() {
		return pathToCommonTrace;
	}
	
	/**
	 * @param pathToCommonTrace
	 */
	public void setPathToCommonTrace(String pathToCommonTrace) {
		this.pathToCommonTrace = pathToCommonTrace;
	} 
}
